import request from '@/api/myrequest'

// 获取资源列表
export function getResourceList(resourceQuery) {
  return request({
    url: '/resources',
    method: 'get',
    params: resourceQuery
  })
}

// 根据ID获取资源
export function getResourceById(id) {
  return request({
    url: '/api/v1/permission/resource',
    method: 'get',
    params: { id }
  })
}

// 插入新资源
export function insertResource(resourceDTO) {
  return request({
    url: '/resource',
    method: 'post',
    data: resourceDTO
  })
}

// 更新资源
export function updateResource(resourceDTO) {
  return request({
    url: '/resource',
    method: 'put',
    data: resourceDTO
  })
}

// 根据ID删除资源
export function deleteResourceById(id) {
  return request({
    url: '/resource',
    method: 'delete',
    params: { id }
  })
}

// 批量删除资源
export function deleteResourceByIdList(idList) {
  return request({
    url: '/batch/resource',
    method: 'delete',
    data: idList
  })
}

// 获取资源树
export function getTreeResource() {
  return request({
    url: '/tree/resource',
    method: 'get'
  })
}

// 根据子系统id获取资源树
export function getSubSystemListBySubSystemId(id, name) {
  return request({
    url: '/subsystem/tree/resource',
    method: 'get',
    params: { id, name }
  })
}

// 获取子系统列表
export function getSubSystemList(id) {
  return request({
    url: '/resource/subsystems',
    method: 'get',
    params: { id }
  })
}
